using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Script.Services;
using BLL;
namespace mmq
{

    public partial class WebSite : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                TreeEditor2.SelectAction = TreeNodeSelectAction.Expand;
                TreeEditor2.NavigateUrl = @"javascript:OnNodeClick('{0}','{1}','" + label_category.ClientID + "','" + hf_selectedValue.ClientID+ "','" + btn_Ok.ClientID + "'); ";
            }
            
            int selectedId = -1;
            if (!string.IsNullOrEmpty(TreeEditor1.SelectedValue))
                selectedId = int.Parse(TreeEditor1.SelectedValue);
            DataSet ds = BLL.WebSiteManager.GetAllWebSites(selectedId, HttpContext.Current.Profile.GetPropertyValue("PreferredCulture").ToString());
            MainPage.DataSource = ds.Tables["Category"];
            Page.DataBind(); 
        }
        protected void btn_Ok_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtScreenShot.Text) && !string.IsNullOrEmpty(txtBoxRefUrl.Text) && HtmlEditor1.Text.Length <= 512 && !string.IsNullOrEmpty(HtmlEditor1.Text) && !string.IsNullOrEmpty(txtBoxTitle.Text))
            {
                BLL.WebSiteManager.AddWebSite
                    (
                      Convert.ToInt32(hf_selectedValue.Value)
                    , HttpContext.Current.User.Identity.Name
                    , ddl_Language.SelectedValue
                    , txtBoxTitle.Text
                    , HtmlEditor1.Text
                    , txtBoxRefUrl.Text
                    , txtScreenShot.Text 
                    );
            }
        }
        protected void btnUploaded_Click(object sender, System.EventArgs e)
        {
        }

    }
}
